package com.sskj.mine.presenter;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.SPUtil;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.SPConfig;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.util.CommonUtil;
import com.sskj.mine.bean.PayWayItem;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.SecurityActivity;

import java.io.File;
import java.util.List;


/**
 * @author Hey
 * Create at  2019/05/01
 */
public class SecurityPresenter extends BasePresenter<SecurityActivity> {


    public void cancelShop() {
        OkGo.<HttpData<Object>>get(HttpConfig.BASE_URL + HttpConfig.SHOPCANCEL)
                .params("id", SPUtil.get(SPConfig.ID, ""))
                .execute(new JsonCallBack<HttpData<Object>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<Object>> response) {
                        HttpData<Object> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            ToastUtil.showShort(httpData.getMsg());
                            mView.cancelShopSuccess();
                        }
                    }
                });
    }


    //开启谷歌验证
    public void openGoogleVerify(String code) {
        OkGo.<HttpData>get(HttpConfig.BASE_URL + HttpConfig.OPENCHROME)
                .params("code", code)
                .params("stockUserId", SPUtil.get(SPConfig.ID, ""))
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        mView.setGoogleVerifySuccess();
                    }
                });
    }

    //关闭谷歌验证
    public void closeGoogleVerify(String code, String code2) {
        OkGo.<HttpData>get(HttpConfig.BASE_URL + HttpConfig.CLOSECHROME)
                .params("code", code)
                .params("stockUserId", SPUtil.get(SPConfig.ID, ""))
                .params("telCode", code2)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        mView.setGoogleVerifySuccess();
                    }
                });
    }

    //解绑谷歌验证
    public void untriedGoogleVerify(String code, String code2) {
        OkGo.<HttpData>get(HttpConfig.BASE_URL + HttpConfig.UNBINDCHROME)
                .params("code", code)
                .params("stockUserId", SPUtil.get(SPConfig.ID, ""))
                .params("telCode", code2)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        mView.setGoogleVerifySuccess();
                    }
                });
    }


    // 解除谷歌认证
    public void toggleGoogleVerify(int googleType, String code, String mobileCode, String mobile) {
        OkGo.<HttpData<Object>>post(HttpConfig.BASE_URL + HttpConfig.SET_GOOGLE_VERIFY)
                .params("act", googleType)
                .params("dyGoodleCommand", code)
                .params("code", mobileCode)
                .params("mobile", mobile)
                .execute(new JsonCallBack<HttpData<Object>>() {
                    @Override
                    public void onSuccess(Response<HttpData<Object>> response) {
                        mView.setGoogleVerifySuccess();
                    }
                });
    }
}
